package com.edushare.common.vo;

import com.edushare.common.util.StringUtil;
import com.edushare.common.util.SystemUtils;
import com.edushare.common.util.URLUtils;
import com.edushare.common.vo.auto._FilesUploaded;

public class FilesUploaded extends _FilesUploaded {

	private static final long serialVersionUID = -5171770073006983339L;

	public String getFileDownloadUrl(){
		return URLUtils.createFileDownloadURL(this);
	}

	public String getFileRelativePath(String version) {
		String relativePath = getFileRelativePath();
		if(!StringUtil.isValid(version))
			return relativePath;
		String extn = relativePath.substring(relativePath.lastIndexOf("."));
		String fileName = relativePath.substring(0,relativePath.lastIndexOf("."));
		return fileName + "_" + version + extn;
	}
	
	public String getFileAbsolutePath(){
		String basePath = SystemUtils.getRootDirectoryPath();
		return basePath + "/" + getFileRelativePath();
	}
}
